home *** CD-ROM | disk | FTP | other *** search
/ Delphi Magazine Collection 2001 / Delphi Magazine Collection 20001 (2001).iso / DISKS / Issue62 / ClassEng / Listing4.pas < prev    next >
Pascal/Delphi Source File  |  2000-09-01  |  792b  |  29 lines

  1. Listing 4
  2.  
  3. TParent = class(TObject)
  4. public
  5.   procedure DecideEarly;
  6.   procedure DecideLate; virtual;
  7. end;
  8. TChild = class(TParent)
  9. public
  10.   procedure DecideEarly;
  11.   procedure DecideLate; override;
  12. end;
  13. ...
  14. Parent: TParent;
  15. Child: TChild;
  16. ParentalChild: TParent;
  17. ...
  18. Parent := TParent.Create;
  19. Child := TChild.Create;
  20. ParentalChild := TChild.Create; // TChild assigned to TParent!
  21. // early bound (non-virtual) calls
  22. Parent.DecideEarly;         // TParent version called
  23. Child.DecideEarly;          // TChild version called
  24. ParentalChild.DecideEarly;  // TParent version called
  25. // late bound (virtual) calls
  26. Parent.DecideLate;          // TParent version called
  27. Child.DecideLate;           // TChild version called
  28. ParentalChild.DecideLate;   // TChild version called
  29.